package com.chanyachting.emall.domain;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.chanyachting.emall.dao.YellowpagekeywordDAO;
import com.chanyachting.emall.domain.base.BaseYellowpagekeyword;

/**
 * This is the object class that relates to the yellowpagekeyword table.
 * Any customizations belong here.
 */
public class Yellowpagekeyword extends BaseYellowpagekeyword {

/*[CONSTRUCTOR MARKER BEGIN]*/
	public Yellowpagekeyword () {
		super();
	}

	/**
	 * Constructor for primary key
	 */
	public Yellowpagekeyword (java.lang.Integer _id) {
		super(_id);
		
		Yellowpagekeyword keyword=(Yellowpagekeyword)new YellowpagekeywordDAO().load(Yellowpagekeyword.class, _id);
		
		if(keyword!=null){
			
			try {
				BeanUtils.copyProperties(this, keyword);
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/**
	 * Constructor for required fields
	 */
	public Yellowpagekeyword (
		java.lang.Integer _id,
		java.lang.Integer _productcategoryId,
		java.lang.Integer _subcategoryId) {

		super (
			_id,
			_productcategoryId,
			_subcategoryId);
	}
/*[CONSTRUCTOR MARKER END]*/
	
	public static List list(){
		
		return new YellowpagekeywordDAO().find("from Yellowpagekeyword");
		
	}
	
	
	public static List listBySubCategory(int subcategoryId){
		
		String args[]={String.valueOf(subcategoryId)};
		
		return new YellowpagekeywordDAO().find("from Yellowpagekeyword where subcategoryId=?",args);
	}
	
	
	public boolean save(){
		
		new YellowpagekeywordDAO().save(this);
		
		return true;
	}
	
	public boolean update(){
		
		new YellowpagekeywordDAO().update(this);
		
		return true;
	}
	
	public boolean delete(){
		
		new YellowpagekeywordDAO().delete(this);
		
		return true;
	}
	
	
	
	
}